# 导包
import logging

import requests

from config import BASE_URL

# 获取图片验证码的接口
BASE_VI_CODE_URL = BASE_URL + "/api/captchaImage"
response = requests.get(BASE_VI_CODE_URL)
# 对获取验证码响应进行查看

# 打印响应状态码
logging.info(response.status_code)
# 打印JSON格式
logging.info(response.json())
# 打印文本格式
logging.info(response.text)

# 将JSON数据中的uuid健名的值转换成uuid变量方便调用
uuid = response.json()["uuid"]

# 发送登录请求
login_data = {"username": "admin", "password": "HM_2023_test", "code": "2", "uuid": uuid}
BASE_LOGIN_URL = BASE_URL + "/api/login"
response = requests.post(BASE_LOGIN_URL, json=login_data)
# 对登录响应进行查看

# 打印响应状态码
logging.info(response.status_code)
# 打印JSON格式
logging.info(response.json())
# 打印文本格式
logging.info(response.text)
